package main

import (
	"fmt"
	"time"
)

/**
  日期操作
*/
func main() {
	//获取当前日期
	now := time.Now()
	fmt.Println(now)
	//获取年月日
	year := now.Year()
	//月份需要转换下类型
	month := int(now.Month())
	day := now.Day()
	fmt.Printf("%d年%d月%d日  ", year, month, day)
	//时分秒
	hour := now.Hour()
	minute := now.Minute()
	second := now.Second()
	fmt.Printf("%d时%d分%d秒\n  ", hour, minute, second)
	//格式化日期,注意这个日期内容必须填写2006-01-02 15:04:05这个
	format := now.Format("2006-01-02 15:04:05")
	fmt.Printf(format)

}
